package com.woniu.inlet.web;

import com.woniu.exception.ReportedForWorkException;
import com.woniu.outlet.client.OrderClient;
import com.woniu.outlet.client.PlanClient;
import com.woniu.outlet.po.ProPlanPo;
import com.woniu.outlet.po.Progress;
import com.woniu.service.ProgressService;
import com.woniu.util.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "生产计划controller")
@RequestMapping("Progress")
public class ProductionPlanController {
    @Autowired
    private ProgressService progressService;
    @Autowired
    private PlanClient planClient;
    @Autowired
    private OrderClient orderClient;

//    @GetMapping("getProgressByPlanId")
//    @ApiOperation("通过生产计划id查询所有的工序")
//    public ResponseEntity<String> getProgressByPlanId(Long planId,String progressName){
//        List<Progress>  progressList = progressService.getProgressByPlanId(planId);
//        return new ResponseEntity<>(progressList, HttpStatus.OK);
//    }

    @GetMapping("getPlanIdByOderCode")
    @ApiOperation("通过订单id查询对应的生产计划id")
    public ResponseResult<ProPlanPo> getPlanIdByOderCode(Long id){
        ProPlanPo data = planClient.findAllProPlan(id).getData();
        return new ResponseResult(data.getId(),"生产计划id",200);
    }

    @GetMapping("findIdByOrderNo")
    @ApiOperation("根据订单编号查询订单id")
    public ResponseResult<Long> findIdByOrderNo(String orderCode){
        Long data = orderClient.findIdByOrderNo(orderCode).getData();
        return new ResponseResult(data,"订单id",200);
    }
}
